stage.set_background("underwater")
score = 0
score_board = codesters.Display(score)
weak_pws = ["password", "password123", "hello1", "snuffles", "123456"]
strong_pws = ["GgbvTa581!@", "@Mjrc0olguy!", "007jmSB0nd!", "108turt!es762", "Avv3SoMe!305"]
all_pws = weak_pws + strong_pws
# text = codesters.Text("text", x, y, "color")
password = codesters.Text("password", 100, 200, "red")
def interval():
# add any other actions...
rand_x = random.randint(-225, 225)
rand_y = random.randint(-225, 225)
rand_pw = random.choice(all_pws)
password.set_text(rand_pw)
stage.event_interval(interval, 2)
t = codesters.Teacher()
try:
tval1_line = t.find_function('go_to')[0][0]
tval1 = t.get_indent_at_line(tval1_line)
tval2 = t.find_function('go_to')[0][1].replace(' ', '')
except:
tval1_line = "DNE"
tval1 = "DNE"
tval2 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == 4 and tval2 == "password.go_to(rand_x,rand_y)", "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add a Go To command inside your Interval Event?")
t1.add_failure('rand_x' not in tval2 or 'rand_y' not in tval2, "Make sure you change both coordinates in the Go To command!")
t1.add_failure('rand_y,rand_x' in tval2, "Oops! Did you mix up the order of your x and y coordinates?")
t1.add_failure(tval1 < 4, "Did you indent your Go To command 4 spaces inside your Interval Event?")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)